home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickTime / Programming Stuff / Documentation / develop articles / develop Issue 23 / Internet Config / IC 1.1 / ICAppSourceKit1.1 / ICEditPrefAppleEvents.p < prev    next >
Encoding:
Text File  |  1995-04-24  |  1.4 KB  |  59 lines  |  [TEXT/PJMM]

  1. unit ICEditPrefAppleEvents;
  2.  
  3. interface
  4.  
  5.     const
  6.         EPSuite = 'ICAp';
  7.         EPEvent = 'ICAp';
  8. { Direct parameter is key }
  9.         EPDestination = 'dest'; { pass true if you want the default preference file.  defaults to current pref file (or default pref file if none)  }
  10.  
  11.     procedure SetupEditPrefAppleEvent;
  12.  
  13. implementation
  14.  
  15.     uses
  16.         AppleEvents,{}
  17.         ICGlobals, ICDocument;
  18.  
  19. {$PUSH}
  20. {$R-}
  21.     function HandleEditPrefAE (event, reply: AppleEvent; ignored: longInt): OSErr;
  22.         var
  23.             key: Str255;
  24.             typ: DescType;
  25.             actualSize: Size;
  26.             fs: FSSpec;
  27.             usefss, usecurrent: boolean;
  28.             err: OSErr;
  29.     begin
  30.         usefss := true;
  31.         usecurrent := false;
  32.         err := AEGetParamPtr(event, EPDestination, typeFSS, typ, @fs, sizeof(fs), actualSize);
  33.         if err <> noErr then begin
  34.             usefss := false;
  35.             usecurrent := true;
  36.             if AEGetParamPtr(event, EPDestination, typeBoolean, typ, @fs, sizeof(fs), actualSize) = noErr then begin
  37.                 usecurrent := false;
  38.             end;
  39.         end;
  40.         err := AEGetParamPtr(event, keyDirectObject, typeChar, typ, @key[1], 255, actualSize);
  41.         if err <> noErr then begin
  42.             actualSize := 0;
  43.         end;
  44.         key[0] := chr(actualSize);
  45.         err := EditPreference(key, fs, usefss, usecurrent);
  46.         HandleEditPrefAE := err;
  47.     end;
  48. {$POP}
  49.  
  50.     procedure SetupEditPrefAppleEvent;
  51.         var
  52.             junk: OSErr;
  53.     begin
  54.         if has_AppleEvents then begin
  55.             junk := AEInstallEventHandler(EPSuite, EPEvent, @HandleEditPrefAE, 0, false);
  56.         end;
  57.     end;
  58.  
  59. end.